package br.com.jvet.bean;

import java.util.List;

import javax.persistence.TypedQuery;

import br.com.jvet.entidade.Raca;

public class RacaBean extends DAO implements GenericBean {

	@Override
	public <E> void incluir(E obj) {
		super.getEntityManager().persist(obj);
	}

	@Override
	public <E> void alterar(E obj) {
		super.getEntityManager().merge(obj);

	}

	@Override
	public <E> void excluir(E obj) {
		super.getEntityManager().remove(obj);

	}

	@Override
	public <E> Object consultar(E obj) {

		return super.getEntityManager().find(Raca.class, obj);
	}

	@SuppressWarnings("unchecked")
	@Override
	public <E> List<E> listar() {

		TypedQuery<?> query = super.getEntityManager().createQuery("SELECT r FROM "
				+ "tbraca" + " r", Raca.class);
		List<E> resultList =  (List<E>) query.getResultList();
		return resultList;
	}

}
